package com.apes.fn.scm.rebatePolicy.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.product.model.Brand;
import com.apes.scm.masterdata.product.model.Classify;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：返利政策品类加品牌维度
 *
 * @author cyy
 * @time 14:00
 * @date 2023/9/20
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = RebatePolicyClassifyBrand.CONST_TABLE_NAME)
public class RebatePolicyClassifyBrand extends BaseModel {
    public static final String CONST_TABLE_NAME = "fn_rebate_policy_brand";
    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "返利政策品类加品牌维度编码", padding = 8)
    @Comment("编码")
    private String id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "rebate_policy_id", referencedColumnName = "id")
    @Comment("返利政策号")
    private RebatePolicy rebatePolicy;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "classify_id", referencedColumnName = "id")
    @Comment("品类")
    private Classify classify;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "brand_id", referencedColumnName = "id")
    @Comment("品牌")
    private Brand brand;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "rebate_benchmark", referencedColumnName = "id")
    @Comment("计算基数")
    private Enumeration rebateBenchmark;

    @Column(name = "rebate", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("返利率/额")
    private double rebate = 0;
}
